﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entities;
using Entities.Enums;

namespace Interview_Prov.Private.Admin
{
    public partial class AddInterview : System.Web.UI.Page
    {
        private Business.BusinessLogic bll = new Business.BusinessLogic();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (bll.InterviewExist(TextBox2.Text))
            {
                Label1.Visible = true;
                return;
            }
            var interv = new Interview();
            interv.State = InterviewState.Draft;
            interv.Title = TextBox2.Text;
            interv.Questions = new List<Question>();
            interv.AuthorID = Global.UserID;
            int id = bll.CreateInterviewRet(interv);
            if (id != -1)
            {
                Response.Redirect(string.Format("~\\Private\\User\\InterviewPage.aspx?InterviewID={0}&EditMode=1", id), true);
            }
            else
            {
                Response.Redirect("Errors\\InterviewCreationError.aspx", true);
            }
        }
    }
}